# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=sagan
pkgver=2.0.2
_pkgver=2-0.2
pkgrel=1
pkgdesc='A snort-like log analysis engine.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-ids' 'blackarch-defensive')
url='https://quadrantsec.com/sagan_log_analysis_engine/'
license=('GPL')
depends=('sagan-rules' 'pcre' 'libdnet' 'libesmtp' 'mariadb-clients'
         'postgresql-libs' 'liblognorm' 'geoip' 'json-c' 'libfastjson'
         'libyaml' 'geoip2-database' 'geoip-database-extra' 'geoip-database')
makedepends=('git')
options=('!makeflags' '!emptydirs')
conflicts=('sagan' 'sagan-svn')
replaces=('sagan-svn')
source=("https://download.quadrantsec.com/source/sagan/$pkgname-$pkgver.tar.gz")
sha512sums=('4753e984156c930b390e06802e918c2660e802fb1f07d7e014898f375fe4f8fd787a5b96e239998fed720147bc9a22906b42c75a88cc2695c1d836187d957817')

build() {
  cd "$pkgname-v-$_pkgver"

  ./autogen.sh

  ./configure --enable-esmtp --disable-geoip --prefix=/usr --sysconfdir=/etc \
    --sbindir=/usr/bin --enable-system-strstr

  make

  sed "s:^var RULE_PATH.*$:var RULE_PATH /usr/share/sagan/rules/:" \
    etc/sagan.yaml > etc/sagan.yaml.new

  mv etc/sagan.yaml.new etc/sagan.yaml
}

package() {
  cd "$pkgname-v-$_pkgver"

  make DESTDIR="$pkgdir" install
}

